from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC

import os
import time
from time import sleep

from selenium.webdriver.support.wait import WebDriverWait

from common.recordlog import logs
from conf.setting import DIR_BASE


driver = webdriver.Firefox()
driver.get("https://www.baidu.com/")
driver.maximize_window()
driver.find_element(By.CSS_SELECTOR,"#s-top-loginbtn").click()
# iframe = WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.CSS_SELECTOR, "#passportbox > iframe:nth-child(1)")))
# print(iframe)
# driver.switch_to.frame("passport_iframe")
# .login-box-tabs-items > span:nth-child(3)
password_tab = WebDriverWait(driver, 10).until(
    EC.element_to_be_clickable((By.CSS_SELECTOR, "#TANGRAM__PSP_11__changeSmsCodeItem")))
print(password_tab)
sleep(3)
password_tab.click()

